<<<<<<< HEAD
# 地址


url1="http://218.75.72.114:5082/"
url2="http://www.geely.com/"
url3="http://218.75.72.114:5082/introduce/intro/index.html"
url4="http://www.geely.com/news/newscenter/mtbd/34075.html"



 # run 函数 执行并发测验并记录
 # 参数1 执行序号，用于生成文件序号
 # 参数2 访问链接数 
 # 参数3 并发数
 # 参数4 时间限制 [可选]
function run {

	i=$1
	n=$2
	c=$3
	t=$4

	#the_day=` date +%Y-%m-%d ` 
	the_day=`date` 
	declare -i j=0

	for k in $url1 $url2 $url3 $url4; do
		j=$j+1

		echo $j
		echo $k

		touch boc-ab-${i}-url${j}-list.txt
		touch boc-ab-${i}-url${j}-over.txt

		file_list=boc-ab-${i}-url${j}-list.txt 
		file_over=boc-ab-${i}-url${j}-over.txt
		file_png=boc-ab-${i}-url${j}-list.png
		#file_png_tile="${the_day} connectioner:${c} Request:${2}"
		file_png_tile="${the_day} 并发数:${c} 发送请求数:${2}"

		date >> $file_over 
		echo "==============================================================" >> $file_over 
		echo "" >> $file_over 


		if [[ $t > 0 ]]; then
			echo "限定执行时间：$t > ab -n $n -c $c -t $t $k"
			echo "限定执行时间：$t 
ab -n $n -c $c -t $t $k
---------------------------------------" >> $file_over
			ab -n $n -c $c -t $t -g $file_list $k | tee >> $file_over 
		else
			echo "执行： > ab -n $n -c $c $k"
			echo "执行：
ab -n $n -c $c $k
---------------------------------------" >> $file_over
			ab -n $n -c $c -g $file_list $k | tee >> $file_over 

		fi

		echo "" >> $file_over 
		echo "==============================================================" >> $file_over
		date >> $file_over

			#gnuplot -e 'set terminal png; set output "${file_png}"; set xlabel "Request"; set ylabel "ms"; plot "ab-plot.txt" using 10 with lines title "Response time"'

		# 打印图表
		gnuplot <<- EOF
			datafile="$file_list"
			set title  "$file_png_tile \n $k"
			#set xlabel "Request"
			#set ylabel "ms"
			set xlabel "处理请求数"
			set ylabel "时耗(毫秒)"
			set terminal png
			set terminal pngcairo size 960,600 enhanced
			set output "${file_png}"
			plot datafile using 7 with lines title "ctime", datafile using 8 with lines title "dtime", datafile using 9 with lines title "ttime", datafile using 10 with lines title "wait" 
		EOF

		eog $file_png &
	done
}

echo "第1次; 100并发 100访问"
run 1 100 100

echo "第2次; 200并发 200访问"
run 2 200 200 

echo "第3次; 100并发 1000访问"
run 3 1000 100

echo "第4次; 200并发 1000访问"
run 4 1000 200 







=======
# 地址


url1="http://test1"
url2="http://test2"
url3="http://test3"
url4="http://test4"



 # run 函数 执行并发测验并记录
 # 参数1 执行序号，用于生成文件序号
 # 参数2 访问链接数 
 # 参数3 并发数
 # 参数4 时间限制 [可选]
function run {

	i=$1
	n=$2
	c=$3
	t=$4

	#the_day=` date +%Y-%m-%d ` 
	the_day=`date` 
	declare -i j=0

	for k in $url1 $url2 $url3 $url4; do
		j=$j+1

		echo $j
		echo $k

		touch boc-ab-${i}-url${j}-list.txt
		touch boc-ab-${i}-url${j}-over.txt

		file_list=boc-ab-${i}-url${j}-list.txt 
		file_over=boc-ab-${i}-url${j}-over.txt
		file_png=boc-ab-${i}-url${j}-list.png
		#file_png_tile="${the_day} connectioner:${c} Request:${2}"
		file_png_tile="${the_day} 并发数:${c} 发送请求数:${2}"

		date >> $file_over 
		echo "==============================================================" >> $file_over 
		echo "" >> $file_over 


		if [[ $t > 0 ]]; then
			echo "限定执行时间：$t > ab -n $n -c $c -t $t $k"
			echo "限定执行时间：$t 
ab -n $n -c $c -t $t $k
---------------------------------------" >> $file_over
			ab -n $n -c $c -t $t -g $file_list $k | tee >> $file_over 
		else
			echo "执行： > ab -n $n -c $c $k"
			echo "执行：
ab -n $n -c $c $k
---------------------------------------" >> $file_over
			ab -n $n -c $c -g $file_list $k | tee >> $file_over 

		fi

		echo "" >> $file_over 
		echo "==============================================================" >> $file_over
		date >> $file_over

			#gnuplot -e 'set terminal png; set output "${file_png}"; set xlabel "Request"; set ylabel "ms"; plot "ab-plot.txt" using 10 with lines title "Response time"'

		# 打印图表
		gnuplot <<- EOF
			datafile="$file_list"
			set title  "$file_png_tile \n $k"
			#set xlabel "Request"
			#set ylabel "ms"
			set xlabel "处理请求数"
			set ylabel "时耗(毫秒)"
			set terminal png
			set terminal pngcairo size 960,600 enhanced
			set output "${file_png}"
			plot datafile using 7 with lines title "ctime", datafile using 8 with lines title "dtime", datafile using 9 with lines title "ttime", datafile using 10 with lines title "wait" 
		EOF

		eog $file_png &
	done
}

echo "第1次; 100并发 100访问"
run 1 100 100

echo "第2次; 200并发 200访问"
run 2 200 200 

echo "第3次; 100并发 1000访问"
run 3 1000 100

echo "第4次; 200并发 1000访问"
run 4 1000 200
>>>>>>> 0adcc96b27890b2e30914f127aa03ba462fa8189
